import sys
import getopt
import time
import json
import datetime
import collections
import argparse
from engine.report import Report

class Statler:
	report = None

	def __init__(self):
		pass
		#setup params

	def get_stats_summed_by_week(self, d_from, d_to):
		print "Here is Statler "

	def get_stats_by_day(self, d_from, d_to):
		pass
	

	def report(self):
		report = Report("Test", "StartDate", "EndDate", "GroupBy")
		print report.apps[1].name
		report.apps[1].get_app_stats()



def main(argv):
	global _verbose
	outfile = 'o.csv'

	statler = Statler()

	parser = argparse.ArgumentParser(description = 'Statler retrieves flurry stats and delivers them to you')

	parser.add_argument("-o", "--outfile", help = "specify output file")
	parser.add_argument("-v", "--verbose", action = "count", help = "verbosity level - up to 3")
	parser.add_argument("-s", "--start", type = str, help = "extract stats from (YYYY-MM-DD)", default = "today")
	parser.add_argument("-t", "--to", type = str, help = "extract stats to (YYYY-MM-DD)", default = "today")
	parser.add_argument("action", choices = ["dev", "week", "day"])
	parser.add_argument('--version', action = "version", version = '%(prog)s 0.1')

#	parser.parse_args(['week'])

	args = parser.parse_args()

	if args.verbose:
		_verbose = args.verbose

	if args.action == "week":
		statler.get_stats_summed_by_week(args.start, args.to)
		# Get stats for app summed by week in the specified time range
		pass
	elif args.action == "day":
		statler.get_stats_by_day(args.start, args.to)
		# Get daily stats for app in the specified time range
		pass
	elif args.action == "dev":
		statler.report()

#	getAllApplications()

if __name__ == "__main__":
	main(sys.argv[1:])


